package com.oceansoft.mobile.econsole.modules.weixin.controller;

import com.oceansoft.mobile.econsole.common.util.StringUtils;
import com.oceansoft.mobile.econsole.modules.base.controller.BaseController;
import com.oceansoft.mobile.econsole.modules.member.entity.WtMember;
import com.oceansoft.mobile.econsole.modules.member.service.IMemberService;
import com.oceansoft.mobile.econsole.modules.member.service.IWtMemberService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 我的办件
 */
@Controller
@RequestMapping("weixin/transact")
public class TransactController extends BaseController {

    @Resource
    IMemberService memberService;
    @Resource
    IWtMemberService wtMemberService;

	/**
     * 我的办件
     */
    @RequestMapping(value = "index",method = RequestMethod.GET)
    public String gotoIndex(Model model,HttpServletRequest request) {
        String guid=request.getParameter("userGuid");
        WtMember member = wtMemberService.getWtMemberByUserGuid(guid);
        model.addAttribute("member",member);
        return "weixin/product/mytransact";
    }


    /**
     * 办件详情
     */
    @RequestMapping(value = "details/{prjguid}", method = RequestMethod.GET)
    public String gotoDetails(@PathVariable("prjguid")String prjguid, Model model,HttpServletRequest request) {
//用户信息是否绝对存在下 现取缓存
//        String userGuid = request.getParameter("userGuid");
//        if(StringUtils.isBlank(userGuid)){
            WtMember member = getWxMemberSession();
            model.addAttribute("loginId",member.getUserName());
            model.addAttribute("userName",member.getAliasName());
//        }else {
//            WtMember wtMember = wtMemberService.getWtMemberByUserGuid(userGuid);
//            model.addAttribute("loginId",wtMember.getUserName());
//            model.addAttribute("userName",wtMember.getAliasName());
//        }

        model.addAttribute("prjguid",prjguid);
        return "weixin/product/transact_details";
    }

}
